package com.ss.ttm.player;

import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.view.Surface;

class n implements ServiceConnection {
    e a;
    d b;
    o c;
    private static final String d = n.class.getSimpleName();

    n(o arg2) {
        this.b = new q(this);
        this.c = arg2;
    }

    static final String a(long arg6, String arg8, String arg9) {
        StringBuilder v0 = new StringBuilder(512);
        v0.append('<');
        v0.append(Thread.currentThread().getId());
        v0.append(',').append(n.d);
        v0.append(',').append(arg8);
        v0.append(',').append(android.support.design.a.w());
        v0.append('>').append("player:").append(arg6).append(",info:").append(arg9);
        return v0.toString();
    }

    public final int a(long arg6, int arg8, int arg9) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                return this.a.getIntOption(arg6, arg8, arg9);
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "getIntOption,key:" + arg8;
        String v0_1 = v0 == null ? "player is null" : v0.getClass().getSimpleName() + ":" + v0.getMessage();
        this.b(arg6, n.a(arg6, v1, v0_1));
        return arg9;
    }

    public final int a(long arg8, int arg10, long arg11) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                int v0_1 = this.a.setLongOption(arg8, arg10, arg11);
                return v0_1;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "setLongOption,key:" + arg10;
        String v0_2 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg8, n.a(arg8, v1, v0_2));
        return -1;
    }

    public final int a(long arg4, int arg6, String arg7) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                int v0_1 = this.a.setStringOption(arg4, arg6, arg7);
                return v0_1;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "setStringOption,key:" + arg6;
        String v0_2 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_2));
        return -1;
    }

    public final int a(long arg4, Surface arg6) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                int v0_1 = this.a.setVideoSurface(arg4, arg6);
                return v0_1;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "setVideoSurface";
        String v0_2 = v0 == null ? "player is null" : v0.getMessage();
        return this.b(arg4, n.a(arg4, v1, v0_2));
    }

    public final String a(long arg6, int arg8) {
        String v1 = null;
        Throwable throwable = null;
        if (this.a != null) {
            try {
                return this.a.getStringOption(arg6, arg8);
            } catch (Throwable v0) {
                v0.printStackTrace();
                throwable = v0;
            }
        }
        String v2 = "getStringOption,key:" + arg8;
        String v0_1 = throwable == null ? "player is null" : throwable.getMessage();
        this.b(arg6, n.a(arg6, v2, v0_1));
        return v1;
    }

    public final void a(long arg4) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.start(arg4);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "start";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final void a(long arg4, float arg6, float arg7) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.setVolume(arg4, arg6, arg7);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "setVolume";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final void a(long arg8, int arg10, int arg11, int arg12) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.mouseEvent(arg8, arg10, arg11, arg12);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "mouseEvent";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg8, n.a(arg8, v1, v0_1));
    }

    public final void a(long arg4, long arg6) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.setNotifyerState(arg4, arg6);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "setNotifyState";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final void a(long arg4, String arg6) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.setDataSource(arg4, arg6);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "setDataSource";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final void a(long arg4, String arg6, int arg7) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.a(arg4, arg6, arg7);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "setLocalPath";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final boolean a() {
        boolean v0 = this.a != null ? true : false;
        return v0;
    }

    private int b(long arg4, String arg6) {
        int v1 = -1;
        if (arg6 != null) {
            this.c.a(arg4, arg6);
        }

        p v0 = this.c.b(arg4);
        if (v0 != null) {
            o.a(v0);
        }

        return v1;
    }

    public static void b() {
    }

    public final int b(long arg4, int arg6, int arg7) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                int v0_1 = this.a.setIntOption(arg4, arg6, arg7);
                return v0_1;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "setIntOption,key:" + arg6;
        String v0_2 = v0 == null ? "player is null" : v0.getMessage();
        return this.b(arg4, n.a(arg4, v1, v0_2));
    }

    public final long b(long arg7, int arg9, long arg10) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                return this.a.getLongOption(arg7, arg9, arg10);
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "getLongOption,key:" + arg9;
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg7, n.a(arg7, v1, v0_1));
        return arg10;
    }

    public final void b(long arg4) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.pause(arg4);
                return;
            } catch (Throwable throwable) {
                v0 = throwable;
                throwable.printStackTrace();
            }
        }

        String v1 = "pause";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final void b(long arg4, float arg6, float arg7) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.rotateCamera(arg4, arg6, arg7);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "rotateCamera";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final void b(long arg4, int arg6) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.setLooping(arg4, arg6);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "setLooping";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final void c(long arg4) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.stop(arg4);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "stop";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final void c(long arg4, int arg6) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.c(arg4, arg6);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "seekTo";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final void d(long arg4) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.reset(arg4);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "reset";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final void e(long arg4) {
        Throwable v0 = null;
        if (this.a != null) {
            try {
                this.a.prepare(arg4);
                return;
            } catch (Throwable throwable) {
                throwable.printStackTrace();
                v0 = throwable;
            }
        }

        String v1 = "prepare";
        String v0_1 = v0 == null ? "player is null" : v0.getMessage();
        this.b(arg4, n.a(arg4, v1, v0_1));
    }

    public final long f(long arg4) {
        long v0 = -1;
        if (this.a != null) {
            try {
                v0 = this.a.setNotifyer(arg4);
            } catch (Throwable v2) {
                v2.printStackTrace();
            }
        }

        return v0;
    }

    public void onServiceConnected(ComponentName arg3, IBinder arg4) {
        e v0 = com.ss.ttm.player.e.a.a(arg4);
        try {
            v0.a(this.b);
            this.a = v0;
        } catch (Throwable v0_1) {
            v0_1.printStackTrace();
        }
    }

    public void onServiceDisconnected(ComponentName arg6) {
        this.a = null;
        this.c.a(0, "<onServiceDisconnected," + android.support.design.a.w() + ">player is will null");
        this.c.b();
    }
}

